package tp.pr1;

public class Street {
	private Place source;
	private Place target;
	private Direction direction;
	
	public Street(Place source,
		      Direction direction,
		      Place target)
	{
	 this.source=source;
	 this.target=target;
	 this.direction=direction;
	}
	

	
	public boolean comeOutFrom(Place place,
            Direction whichDirection)
	{
	if(source==place && direction==whichDirection)return true;
	else if(target==place && whichDirection==Direction.reverseDirection(direction))return true;
	else return false;
	}
	
	public Place nextPlace(Place whereAmI)
	{
	 if (whereAmI!=source && whereAmI!=target ) return null;
	 else
	 	{
		 if(whereAmI==source)return target;
		 else return source;
	 	}
	}
	
}
